﻿//JumbotCms_4.1 Final
using System;
using System.Web;
using System.IO;
using System.Data;
namespace JumbotCms.WebFile.Admin.Attachment
{
    public partial class _upfile : JumbotCms.Common.BasicPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (q("mailsign").Length != 32 || q("adminid") == "")
            {
                Response.Write("验证信息有误");
                Response.End();
            }
            doh.Reset();
            doh.ConditionExpress = "adminid=@adminid and mailsign=@mailsign and adminstate=1";
            doh.AddConditionParameter("@adminid", Str2Int(q("adminid")));
            doh.AddConditionParameter("@mailsign", q("mailsign"));
            if (!doh.Exist("jcms_normal_user"))
            {
                Response.Write("验证信息有误");
                Response.End();
            }
            if (Request.Files.Count > 0)
            {
                for (int j = 0; j < Request.Files.Count; j++)
                {
                    HttpPostedFile oFile = Request.Files[j];
                    string fileExtension = Path.GetExtension(oFile.FileName).ToLower(); //上传文件的扩展名
                    //其实可以在这里定义路径，上传完毕后再返回给前台(相对更安全)，请自行改写
                    string FullPath = Request.QueryString["filename"].ToString() + fileExtension;
                    if (oFile.ContentLength > 0)
                    {
                        oFile.SaveAs(Server.MapPath(FullPath));
                    }
                }
                Response.Write("ok");
            }
            else
                Response.Write("未选择文件");
        }

    }
}
